package chapter01;import java.io.ObjectStreamException;import java.lang.reflect.Array;public class reflect_02 {    public static void main(String[] args) {        int[] arr = {1,2,3};        arr = (int[])goodcp(arr,10);        arr[9] = 100;        System.out.println(arr.length);    }    public static Object goodcp(Object arr, int newlenth)    {        Class cl = arr.getClass();        if(!cl.isArray()) return null; //传入的参数不是数组，返回        //cl == Array        Class componentType = cl.getComponentType();  //获取数组元素类型        Object newarr = Array.newInstance(componentType,newlenth);  //创建一个新的数组        System.arraycopy(arr,0,newarr,0,Math.min(newlenth,Array.getLength(arr)));        return newarr;    }}